class_name ConditionStateTransition
extends StateTransition

## 转移目标状态的名称
var target_state_name: String

## 判断是否可以状态转移的条件函数
var condition_func: Callable

## 状态转移前时调用的函数
var on_transit_func: Callable


func _init(
		init_name: String,
		init_target_state_name: String,
		init_condition_func: Callable,
		init_on_transit_func: Callable
	) -> void:
	super(init_name)
	target_state_name = init_target_state_name
	condition_func = init_condition_func
	on_transit_func = init_on_transit_func


func _try_condition() -> bool:
	return condition_func.call()


func _try_transition() -> String:
	return target_state_name


func _on_transit() -> void:
	on_transit_func.call()
